package cn.tedu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo02 {
    public static void main(String[] args) {
        try(Connection conn=DBUtils.getCoon()) {
            Statement s= conn.createStatement();
//        执行查询的SQL语句
            ResultSet rs=s.executeQuery("select name,job,sal from myemp");
//        从结果集对象中遍历数据
            while (rs.next()){
                String name= rs.getString("name");
                String job= rs.getString("job");
                double sal= rs.getDouble("sal");
                System.out.println(name+":"+job+","+sal);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
